#!/usr/bin/python
# -*- coding: UTF-8 -*-

################################################################################
#
# Copyright (c) 2020 openEuler.org, Inc. All Rights Reserved
#
################################################################################
"""
common time

Authors: zhangjianjun
Date:    04/01/2021 11:01 AM
"""

import time
import datetime


def get_current_time():
    """
    get current time
    """
    now = str(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
    return now


def last_month_date():
    """
    last month date
    :return createTime: string
    """
    today = datetime.datetime.now()
    # 计算偏移量
    offset = datetime.timedelta(days=-30)
    # 获取想要的日期的时间
    last_month = (today + offset).strftime('%Y-%m-%d')
    print("last_month: ", last_month)
    return last_month
